﻿using Microsoft.Extensions.DependencyInjection;

namespace MingYuanyun.WebApi.Abstractions
{
    public static class MvcBuilderExtensions
    {
        public static IMvcBuilder AddJsonDateFormat(this IMvcBuilder mvc, string dateFormat = "yyyy-MM-dd HH:mm:ss")
        {
            mvc.AddJsonOptions(options =>
            {
                //时间格式化
                options.SerializerSettings.DateFormatString = dateFormat;

                //UpperCamelCase
                options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
            });

            return mvc;
        }
    }
}
